#include "progressbarthread.h"
#include "widget.h"
#include <QVBoxLayout>
#include <QDialog>
/*废弃*/
void ProgressBarThread :: run() {
    QDialog* dialog = new QDialog();
    dialog->setWindowTitle("Progress Dialog");

    QProgressBar* progressBar = new QProgressBar(dialog);
    progressBar->setRange(0, 100);

    QVBoxLayout* layout = new QVBoxLayout(dialog);
    layout->addWidget(progressBar);

    dialog->setLayout(layout);
    dialog->show();

    QTimer* timer = new QTimer(dialog);
    connect(timer, &QTimer::timeout, [=]() {
      static int progress = 0;
      progressBar->setValue(progress);
      ++progress;
      if (progress > 100) {
          timer->stop();
          dialog->close();
      }
    });
    timer->start(100); // 每100毫秒更新一次进度
}
